//=============================================================================
// SentinelSSR - Super Shock Rifle!
//=============================================================================
class SentinelSSR extends SentinelWeapon;

var() class<ShockBeamEffect> RedBeamEffectClass;
var() class<ShockBeamEffect> BlueBeamEffectClass;
var() class<ShockBeamEffect> BeamEffectClass;

var() float TraceRange;
var() int Damage;
var() float Momentum;
var() class<DamageType> DamageType;

var bool bBarrel;

simulated function SetTeam()
{
	if(TeamIndex == 0)
		BeamEffectClass = RedBeamEffectClass;
	else
		BeamEffectClass = BlueBeamEffectClass;
}

//So the Sentinel knows when it can fire.
function float MaxRange()
{
	return TraceRange;
}

function Projectile FireAt(vector Start, vector BarrelDir, vector Aim)
{
	local Vector HitLocation, HitNormal;
	local Actor A;
	local ShockBeamEffect Beam;

	if(AmmoAmount < 1)
		return None;

	AmmoAmount -= AmmoPerFire;

	SetTeam();
	PlaySound(FireSound);
	Sentinel.MakeNoise(Loudness);
	FlashCount++;

	if(Level.NetMode != NM_DedicatedServer)
		FlashMuzzleFlash();

	foreach TraceActors(class'Actor', A, HitLocation, HitNormal, Start + Aim * TraceRange, Start)
	{
		if(A == None)
			continue;

		if(A.bWorldGeometry)
			break;

		if(A.IsA('BigShieldSphere') && BigShieldSphere(A).Shield.myteam == sentinel.myteam)
		  continue;

		//Don't hit own shield or instigator or self.
		if(A.IsA('ShieldSphere') && ShieldSphere(A).Shield.Sentinel == sentinel(owner))
			continue;

		if(!A.bProjTarget)
			continue;

		A.TakeDamage(Damage, Sentinel.Instigator, HitLocation, Momentum * Aim, DamageType);
	}

	if(bBarrel)
		Start += vect(0, 6, 0) >> rotator(Aim);
	else
		Start -= vect(0, 6, 0) >> rotator(Aim);

	Start += BarrelDir * ProjSpawnOffset;

	Beam = Spawn(BeamEffectClass,,, Start, rotator(HitLocation - Start));
	Beam.Instigator = None;
	Beam.AimAt(HitLocation, HitNormal);

	bBarrel = !bBarrel;

	return None;
}

defaultproperties
{
     RedBeamEffectClass=Class'XWeapons.SuperShockBeamEffect'
     BlueBeamEffectClass=Class'XWeapons.BlueSuperShockBeam'
     BeamEffectClass=Class'XWeapons.SuperShockBeamEffect'
     TraceRange=17000.000000
     Damage=1000
     Momentum=60000.000000
     DamageType=Class'taskforces.DamTypeSentinelSSR'
     FireRate=1.100000
     FireSound=Sound'WeaponSounds.Misc.instagib_rifleshot'
     ProjSpawnOffset=70.000000
     WeaponAttachmentClass=Class'taskforces.SSRAttachment'
     WeaponOffset=(X=480.000000,Y=85.000000)
     Loudness=1.000000
     MaxAmmo=1
     AmmoAmount=1
     AmmoCost=200
     UpgradeName="ESR Cannon"
     Description="Based on the enhanced version of the ASMD Shock-Rifle technology licensed from Liandri Corp, this attachment is the most powerful that Evil Corp. has to offer. It has an unlimited supply of ammo thanks to the powerful shock-core. Being able to draw on the internal power supply of the Sentinel itself makes it even more powerful than Liandri's hand-held version."
     ActivateSound=Sound'WeaponSounds.ShockRifle.SwitchToShockRifle'
     bInvasionOnly=True
}
